<?php
include_once "xAP-functions/webincludes.php";



$search=$_POST["search"];
$now=date("Y-m-d H:i:s");



$sql="select xAP_TV_Prog.ChannelName,xAP_TV_Prog.ProgName,xAP_TV_Prog.ProgStart,xAP_TV_Prog.ProgEnd,
xAP_TV_Channel.ChannelAlias ,xAP_TV_Prog.ProgDesc,xAP_TV_Channel.ChannelID
from xAP_TV_Prog 
INNER JOIN xAP_TV_Channel on xAP_TV_Channel.ChannelName=xAP_TV_Prog.ChannelName

where  xAP_TV_Prog.ProgEnd>='".$now."' and (
xAP_TV_Prog.ProgName like '%".dbesc($search)."%' or 
xAP_TV_Prog.ProgDesc like '%".dbesc($search)."%'
)
order by xAP_TV_Prog.ProgEnd
limit 20
";
$results=dbquery($sql);


//display
if(count($results)>0){
	echo "<Table width=100%>";
	foreach($results as $row){
		echo "<tr>
		<TD><a href='channel.php?id=".$row["ChannelID"]."'>
		<img src='images/channels/".$row["ChannelName"].".jpg' height=50 width=66></></td>

		<TD align=center class='boldtext' nowrap>".date("D j",strtotime($row["ProgStart"]))."<BR>".date("H:i",strtotime($row["ProgStart"]))."</td>
		<TD class='normaltext'>".$row["ProgName"]."<BR>
		".$row["ProgDesc"]."</td>
		</tr>

		<tr bgcolor='#aaaaaa'><td colspan=100></td></tr>
		";

	}
	echo "</table>";
}
else
{
	echo "<div class='boldtext'>No Programmes Found</div>";
}
?>
